#include <iostream>
#include <math.h>
#include <stdlib.h>

using namespace std;

#define MAXCI	8*10E12+3*10E6	

int getSubString(int s, int max_one, char * string) {
	int max_l = 0, cnt = 0, l = 0, ps = 0, pe = 0;
	
	cnt += string[pe] - '0';

	while(string[pe] != 0 || cnt > max_one) {

//		cout << ps << " " << pe << " " << l << endl; //<< (*pstart) << " " << (*pend) << " "

		if(cnt > max_one) {
			cnt -= string[ps] - '0';
			ps++;
			l--;
//			cout << " >.." << endl;
		} else {
			pe++;
			cnt += string[pe] - '0';
			l++;
//			cout << " ..>" << endl;
		}

		if(l > max_l)
			max_l = l;

	}
//	cout << "--- l=" << max_l << " ---" << endl;
	return max_l;
}

int main () {
	int N, s, m, i;
	char * string;

	cin >> N;

	while(N--) {
		cin >> s >> m;
		string = (char*)malloc(s * sizeof(char));
		cin >> string;
		cout << getSubString(s, m, string) << endl;
		free(string);
	}

	return 0;
}
